package com.example.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.context.UserContext;
import com.example.demo.entity.Consultation;
import com.example.demo.mapper.ConsultationMapper;
import com.example.demo.service.ConsultationService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 咨询表(Consultation)表服务实现类
 *
 * @author makejava
 * @since 2025-01-28 12:36:46
 */
@Service
public class ConsultationServiceImpl extends ServiceImpl<ConsultationMapper, Consultation> implements ConsultationService {

    @Override
    public List<Consultation> listAll() {
        LambdaQueryWrapper<Consultation>lambdaQueryWrapper=new LambdaQueryWrapper<>();
        Long userId = UserContext.getUserId();
        lambdaQueryWrapper.eq(Consultation::getUserId, userId);
        lambdaQueryWrapper.orderByDesc(Consultation::getCreateTime);
        List<Consultation> list = list(lambdaQueryWrapper);
        return list;
    }
}
